<template>
	<view class="personMess">
		<!-- #ifndef MP-ALIPAY -->
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">用户信息</block>
		</cu-custom>
		<!-- #endif -->
		<block v-if="loaded">
			<view class="cu-card case" :class="true?'no-card':''">
				<view class="cu-item shadow">
					<view class="cu-list menu-avatar">
						<view class="cu-item">
							<view class="cu-avatar radius lg" :style="{'background-image':'url('+userInfo.avatar_url+')'}"></view>
							<view class="content">
								<view class="text-grey">{{userInfo.loginname}}</view>
								<view class="text-gray text-sm flex justify-between">
									加入于{{userInfo.create_at|getDate}}
									<view class="text-red text-sm">
										<text class="cuIcon-hotfill margin-lr-xs"></text>
										{{userInfo.score}}
									</view>
								</view>
							</view>
							<view class="action">
								<navigator open-type="navigateTo" :url="'../github/github?user='+userInfo.githubUsername" class="cuIcon-github"></navigator>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange"></text>最近回复
				</view>
			</view>
			<view class="cu-list menu-avatar">
				<view class="cu-item" v-for="item in userInfo.recent_replies" :key="item.id">
					<view class="cu-avatar round sm" :style="{'background-image':'url('+item.author.avatar_url+')'}"></view>
					<view class="content">
						<view class="text-grey">{{item.author.loginname}}</view>
						<view class="text-gray text-sm flex">
							<view class="text-cut">{{item.title}}</view>
						</view>
					</view>
					<view class="action">
						<view class="text-grey text-xs">{{item.last_reply_at|handlTime}}</view>
					</view>
				</view>
			</view>
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange"></text>最近话题
				</view>
			</view>
			<view class="cu-list menu-avatar">
				<view class="cu-item" v-for="item in userInfo.recent_topics" :key="item.id">
					<view class="cu-avatar round sm" :style="{'background-image':'url('+item.author.avatar_url+')'}"></view>
					<view class="content">
						<view class="text-grey">{{item.author.loginname}}</view>
						<view class="text-gray text-sm flex">
							<view class="text-cut">{{item.title}}</view>
						</view>
					</view>
					<view class="action">
						<view class="text-grey text-xs">{{item.last_reply_at|handlTime}}</view>
					</view>
				</view>
			</view>
		</block>
		<view v-else class="cu-load loading"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loaded: false,
				user: 'meetgyp',
				userInfo: ''
			};
		},
		methods: {
			async getUser() { //获取用户信息
				try {
					const res = await this.$api.getUser(this.user);
					this.userInfo = res;
				} catch (err) {}
				this.loaded = true;
			}
		},
		onLoad(options) {
			this.user = options.user;
			this.getUser();
		}
	}
</script>

<style lang="scss">

</style>
